<?php namespace web\home\controller;
/** .-------------------------------------------------------------------
 * |  Software: [HDPHP framework]
 * |      Site: www.hdphp.com
 * |-------------------------------------------------------------------
 * |    Author: 向军 <2300071698@qq.com>
 * |    WeChat: aihoudun
 * | Copyright (c) 2012-2019, www.houdunwang.com. All Rights Reserved.
 * '-------------------------------------------------------------------*/

class Entry extends Common {
	//首页
	public function index() {
//		echo 2;die;
//分配标题数据
        View::with('titleData','曹玲丽博客首页');
        //获取文章数据分配到页面循环
        //获取文章总数
        $total=Db::table('article')->join('category','category_cid','=','cid')
        ->where('is_recycle',0)
        ->orderBy('sendtime','DESC')->count();
//      p($total);die;
        //执行分页动作
        $page=Page::row(3)->make($total);
//      p($page);die;
		//获取文章表关联分类表，获取不在回收站的数据，排序(发布时间排序)，截取几条，个体获取数据
		$arcData=Db::table('article')->join('category','category_cid','=','cid')
		->where('is_recycle',0)
		->orderBy('sendtime','DESC')->limit(Page::limit())->get();
		// p($arcData);die;
		//处理标签数据
		   foreach($arcData as $k=>$v){
		   	$arcData[$k]['tag']=Db::table('article_tag')
		   	->join('tag','tag_tid','=','tid')->field(array('tid','tname'))
		   	->where('article_aid',$v['aid'])->get();
		   }
//		 p($arcData);die;
		View::with('page',$page);
		View::with('arcData',$arcData);
		View::make();	
			
			
			
	}
   


}